import React, { useMemo } from 'react'
import { useHistory, } from 'react-router-dom';
import { Redirect, Switch, Route } from 'react-router-dom'//BrowserRouter模式，路径
import usePreviousCopy from '../../hooks/usePrevious copy';
import WithRouterView from '../../HOC/WithRouterView/index'
import { Tag } from 'antd';
export default function Home(props: any) {
    const [a, dis] = usePreviousCopy();
    console.log('goHome_a', a);
    // const state = useSelector(state => state);
    const history = useHistory();
    // const location = useLocation()
    const goHome = () => {
        const data = { pathname: "/home", query: { id: 'home', tagName: 'Home组件' } } as any
        history.push(data);
        dis({ data, type: 'push' });
    }
    const goHomeSon1 = () => {
        const data = { pathname: "/home/homeSon1", query: { id: 'home', tagName: 'Home组件' } } as any
        history.push(data);
    }
    const goHomeSon2 = () => {
        const data = { pathname: "/home/homeSon2", query: { id: 'home', tagName: 'Home组件' } } as any
        history.push(data);
    }

    return (
        <div>
            <h1>Home</h1>
            <button onClick={goHome}>goHome</button>
            <button onClick={goHomeSon1}>goHomeSon1</button>
            <button onClick={goHomeSon2}>goHomeSon2</button>
            {
                a.map((item: any, index: number) => {
                    return <Tag color="magenta" key={Math.random()} >{item.query
                        .tagName}</Tag>
                })
            }
            <WithRouterView path='/home' level={1} />
        </div>
    )
}
